stage.set_background("schoolentrance")
stage.wait(2)
stage.create_grid_overlay(50, "blue")
stage.set_background_color("azure")
emma = codesters.Sprite("person1")
emma.set_size(0.5)
michael = codesters.Sprite("person2")
michael.set_size(0.5)
emma_x = random.randint(-230,230)
emma_y = random.randint(-230,230)
emma.go_to(emma_x, emma_y)
michael_x = random.randint(-230,230)
michael_y = random.randint(-230,230)
michael.go_to(michael_x, michael_y)
delta_x = emma_x - michael_x
delta_y = emma_y - michael_y
distance = math.sqrt((delta_x**2) + (delta_y**2))
if distance <= 200:
# add your code here
emma.say("I am a sprite.")
emma.load_image("person1_masked")
michael.load_image("person2_masked")
else:
michael.say("I am a sprite.")
t = codesters.Teacher()
default = '"I am a sprite."'
try:
background = t.get_parameters_for_function("set_background")
tval_1 = background[0][0]
except:
tval_1 = "DNE"
says = t.get_parameters_for_function("say")
try:
tval2a = says[0][0]
tval2b = says[1][0]
except:
tval2a = "DNE"
tval2b = "DNE"
try:
params = t.find_block('if')
tval3 = params[0][1]
except:
tval3 = "DNE"
t1 = TestObjective()
t1.add_success(tval_1 != '"schoolentrance"', "Great job!")
t1.add_failure(tval_1 == "DNE", "Did you delete stage.set_background()?")
t1.add_failure(tval_1 == '"schoolentrance"', "Make sure you complete Requirement #1!")
t2 = TestObjective()
t2.add_success(tval2a != default and tval2b != default, "Great job!")
t2.add_failure(tval2a != default and tval2b == default, "Did you change the strings in both michael.say() and emma.say()?")
t2.add_failure(tval2a == default and tval2b != default, "Did you change the strings in both michael.say() and emma.say()?")
t2.add_failure(tval2a == "DNE" or tval2b == "DNE", "Did you delete one of the .say() commands?")
t2.add_failure(tval2a == default and tval2b == default, "Make sure you complete Requirement #2!")
t3 = TestObjective()
t3.add_success('200' not in tval3, "Great job!")
t3.add_failure(tval3 == "DNE", "Did you delete the if statement?")
t3.add_failure('200' in tval3, "Make sure you complete Requirement #3!")
tester = TestManager()
tester.add_test_list([t1, t2, t3])
tester.run_tests()
tester.display_first_feedback()
-
Run Code
-
Activity Submitted!
Submit Work
-
Stop Running Code
-
Show Chart
-
Show Console
-
Reset Code Editor
-
Codesters How To (opens in a new tab)